package com.example.dryyzx.dao;

import com.example.dryyzx.entity.Customer;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.ArrayList;
import java.util.List;

public interface CustomerMapper {
    @Delete({
        "delete from customer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into customer (id, name, ",
        "age, sex, id_number, ",
        "archivesId, type, checkin_time, ",
        "due_date, phone_number, ",
        "birthday, height, marital_status, ",
        "weight, blood_type, remarks, ",
        "bed_id, nursing_level, ",
        "state, remain_times_1, ",
        "remain_times_2, remain_times_3, ",
        "remain_times_4, remain_times_5, ",
        "remain_times_6, health_keeper_id, ",
        "head_portrait)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{age,jdbcType=INTEGER}, #{sex,jdbcType=CHAR}, #{idNumber,jdbcType=CHAR}, ",
        "#{archivesid,jdbcType=CHAR}, #{type,jdbcType=CHAR}, #{checkinTime,jdbcType=TIMESTAMP}, ",
        "#{dueDate,jdbcType=TIMESTAMP}, #{phoneNumber,jdbcType=VARCHAR}, ",
        "#{birthday,jdbcType=DATE}, #{height,jdbcType=REAL}, #{maritalStatus,jdbcType=CHAR}, ",
        "#{weight,jdbcType=REAL}, #{bloodType,jdbcType=CHAR}, #{remarks,jdbcType=VARCHAR}, ",
        "#{bedId,jdbcType=INTEGER}, #{nursingLevel,jdbcType=INTEGER}, ",
        "#{state,jdbcType=CHAR}, #{remainTimes1,jdbcType=INTEGER}, ",
        "#{remainTimes2,jdbcType=INTEGER}, #{remainTimes3,jdbcType=INTEGER}, ",
        "#{remainTimes4,jdbcType=INTEGER}, #{remainTimes5,jdbcType=INTEGER}, ",
        "#{remainTimes6,jdbcType=INTEGER}, #{healthKeeperId,jdbcType=INTEGER}, ",
        "#{headPortrait,jdbcType=LONGVARBINARY})"
    })
    int insert(Customer record);

    @InsertProvider(type=CustomerSqlProvider.class, method="insertSelective")
    int insertSelective(Customer record);

    @Select({
        "select",
        "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
        "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
        "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
        "remain_times_6, health_keeper_id, head_portrait",
        "from customer",
        "where id = #{id,jdbcType=INTEGER} and state in ('入住中','已外出')"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
        @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
        @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
        @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
        @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="height", property="height", jdbcType=JdbcType.REAL),
        @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
        @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
        @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
        @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
        @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
        @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
        @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
        @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
        @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
        @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
        @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
        @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
        @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
        @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
        @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    Customer selectByPrimaryKey(Integer id);

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    Customer selectByPrimaryKey1(Integer id);


    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where id_number = #{idNumber,jdbcType=CHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    Customer selectByIdNumber(String idNumber);//通过身份证号查询

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where name = #{name,jdbcType=CHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    ArrayList<Customer> selectByName(String name);//通过姓名查询

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where name like concat('%',#{name,jdbcType=VARCHAR},'%')"

    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    ArrayList<Customer> selectByHazyName(String name);

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where archivesId = #{archivesId,jdbcType=CHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    Customer selectByArchivesId(String archivesId);//通过档案号查询

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where bed_id = #{bedId,jdbcType=INTEGER} and state in ('入住中','已外出')"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    Customer selectByBedId(Integer bedId);

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    ArrayList<Customer> selectAll();//查询所有


    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where name = #{arg0,jdbcType=CHAR} and id_number = #{arg1,jdbcType=CHAR} and state in ('入住中','已外出')"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    Customer selectByNameIdNumber(String arg0, String arg1);//通过身份证号查询

    @Select({
            "select",
            "id",
            "from customer",
            "order by id DESC LIMIT 1"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
    })
    int selectLastId();

    @Select({
            "select",
            "count(*)",
            "from customer",
            "where state in ('入住中','已外出')"
    })
    int countCustomer();

    @Select({
            "select",
            "count(*)",
            "from customer",
            "where name like concat('%',#{name,jdbcType=VARCHAR},'%') and state in ('入住中','已外出')"
    })
    int countByName(String name);

    @Select({
            "select",
            "count(*)",
            "from customer",
            "where type = #{type,jdbcType=VARCHAR} and state in ('入住中','已外出')"
    })
    int countByType(String type);

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where name like concat('%',#{arg2,jdbcType=VARCHAR},'%') and state in ('入住中','已外出')",
            "limit #{arg0,jdbcType=INTEGER} offset #{arg1,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    List<Customer> selectByLimitOffsetName(Integer arg0,Integer arg1,String arg2);

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where bed_id = #{arg2,jdbcType=INTEGER} and state in ('入住中','已外出')",
            "limit #{arg0,jdbcType=INTEGER} offset #{arg1,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    List<Customer> selectByLimitOffsetBedId(Integer arg0,Integer arg1,int arg2);

    @Select({
            "select",
            "id, name, age, sex, id_number, archivesId, type, checkin_time, due_date, phone_number, ",
            "birthday, height, marital_status, weight, blood_type, remarks, bed_id, nursing_level, ",
            "state, remain_times_1, remain_times_2, remain_times_3, remain_times_4, remain_times_5, ",
            "remain_times_6, health_keeper_id, head_portrait",
            "from customer",
            "where type = #{arg2,jdbcType=VARCHAR} and state in ('入住中','已外出')",
            "limit #{arg0,jdbcType=INTEGER} offset #{arg1,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="age", property="age", jdbcType=JdbcType.INTEGER),
            @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
            @Result(column="id_number", property="idNumber", jdbcType=JdbcType.CHAR),
            @Result(column="archivesId", property="archivesid", jdbcType=JdbcType.CHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.CHAR),
            @Result(column="checkin_time", property="checkinTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="due_date", property="dueDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="phone_number", property="phoneNumber", jdbcType=JdbcType.VARCHAR),
            @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
            @Result(column="height", property="height", jdbcType=JdbcType.REAL),
            @Result(column="marital_status", property="maritalStatus", jdbcType=JdbcType.CHAR),
            @Result(column="weight", property="weight", jdbcType=JdbcType.REAL),
            @Result(column="blood_type", property="bloodType", jdbcType=JdbcType.CHAR),
            @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
            @Result(column="bed_id", property="bedId", jdbcType=JdbcType.INTEGER),
            @Result(column="nursing_level", property="nursingLevel", jdbcType=JdbcType.INTEGER),
            @Result(column="state", property="state", jdbcType=JdbcType.CHAR),
            @Result(column="remain_times_1", property="remainTimes1", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_2", property="remainTimes2", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_3", property="remainTimes3", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_4", property="remainTimes4", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_5", property="remainTimes5", jdbcType=JdbcType.INTEGER),
            @Result(column="remain_times_6", property="remainTimes6", jdbcType=JdbcType.INTEGER),
            @Result(column="health_keeper_id", property="healthKeeperId", jdbcType=JdbcType.INTEGER),
            @Result(column="head_portrait", property="headPortrait", jdbcType=JdbcType.LONGVARBINARY)
    })
    List<Customer> selectByLimitOffsetType(Integer arg0,Integer arg1,String arg2);

    @UpdateProvider(type=CustomerSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Customer record);

    @Update({
        "update customer",
        "set name = #{name,jdbcType=VARCHAR},",
          "age = #{age,jdbcType=INTEGER},",
          "sex = #{sex,jdbcType=CHAR},",
          "id_number = #{idNumber,jdbcType=CHAR},",
          "archivesId = #{archivesid,jdbcType=CHAR},",
          "type = #{type,jdbcType=CHAR},",
          "checkin_time = #{checkinTime,jdbcType=TIMESTAMP},",
          "due_date = #{dueDate,jdbcType=TIMESTAMP},",
          "phone_number = #{phoneNumber,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=DATE},",
          "height = #{height,jdbcType=REAL},",
          "marital_status = #{maritalStatus,jdbcType=CHAR},",
          "weight = #{weight,jdbcType=REAL},",
          "blood_type = #{bloodType,jdbcType=CHAR},",
          "remarks = #{remarks,jdbcType=VARCHAR},",
          "bed_id = #{bedId,jdbcType=INTEGER},",
          "nursing_level = #{nursingLevel,jdbcType=INTEGER},",
          "state = #{state,jdbcType=CHAR},",
          "remain_times_1 = #{remainTimes1,jdbcType=INTEGER},",
          "remain_times_2 = #{remainTimes2,jdbcType=INTEGER},",
          "remain_times_3 = #{remainTimes3,jdbcType=INTEGER},",
          "remain_times_4 = #{remainTimes4,jdbcType=INTEGER},",
          "remain_times_5 = #{remainTimes5,jdbcType=INTEGER},",
          "remain_times_6 = #{remainTimes6,jdbcType=INTEGER},",
          "health_keeper_id = #{healthKeeperId,jdbcType=INTEGER},",
          "head_portrait = #{headPortrait,jdbcType=LONGVARBINARY}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Customer record);

    @Update({
        "update customer",
        "set name = #{name,jdbcType=VARCHAR},",
          "age = #{age,jdbcType=INTEGER},",
          "sex = #{sex,jdbcType=CHAR},",
          "id_number = #{idNumber,jdbcType=CHAR},",
          "archivesId = #{archivesid,jdbcType=CHAR},",
          "type = #{type,jdbcType=CHAR},",
          "checkin_time = #{checkinTime,jdbcType=TIMESTAMP},",
          "due_date = #{dueDate,jdbcType=TIMESTAMP},",
          "phone_number = #{phoneNumber,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=DATE},",
          "height = #{height,jdbcType=REAL},",
          "marital_status = #{maritalStatus,jdbcType=CHAR},",
          "weight = #{weight,jdbcType=REAL},",
          "blood_type = #{bloodType,jdbcType=CHAR},",
          "remarks = #{remarks,jdbcType=VARCHAR},",
          "bed_id = #{bedId,jdbcType=INTEGER},",
          "nursing_level = #{nursingLevel,jdbcType=INTEGER},",
          "state = #{state,jdbcType=CHAR},",
          "remain_times_1 = #{remainTimes1,jdbcType=INTEGER},",
          "remain_times_2 = #{remainTimes2,jdbcType=INTEGER},",
          "remain_times_3 = #{remainTimes3,jdbcType=INTEGER},",
          "remain_times_4 = #{remainTimes4,jdbcType=INTEGER},",
          "remain_times_5 = #{remainTimes5,jdbcType=INTEGER},",
          "remain_times_6 = #{remainTimes6,jdbcType=INTEGER},",
          "health_keeper_id = #{healthKeeperId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Customer record);
}